<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlertPerssionTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $tableNames = config('permission.table_names');

        Schema::table($tableNames['permissions'], function (Blueprint $table) {
            $table->string('cn_name')->unique()->comment('中文名称');
            $table->integer('pid')->default(0)->comment('上级权限');
        });

        Schema::table($tableNames['roles'], function (Blueprint $table) {
            $table->string('cn_name')->unique()->comment('中文名称');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        $tableNames = config('permission.table_names');

        Schema::table($tableNames['permissions'], function (Blueprint $table) {
            $table->dropColumn(['cn_name','pid']);
        });

        Schema::table($tableNames['roles'], function (Blueprint $table) {
            $table->dropColumn('cn_name');
        });
    }
}
